package com.zhhh.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhhh.domain.Shop;
import com.zhhh.domain.Store;
import com.zhhh.repository.StoreRepository;

import java.util.ArrayList;
import java.util.List;

/**
 */
@Service
public class StoreService {
	@Autowired
	private StoreRepository storeDao;

	/**
	 * 展示商店商品
	 */
	public List<Shop> findByShopList(Integer id,Pageable pageable) {
		List<Store> list = storeDao.findByShopList(id,pageable);
		List<Shop> shopList = new ArrayList<Shop>();
		for (Store store : list) {
			System.out.println(store.getName());
			for (Shop shop : store.getShops()) {
				System.out.println(shop.getName());
				shopList.add(shop);
			}
		}
		return shopList;
	}
}
